<template>
  <Table :columns="columns11" :data="data10" border ></Table>
</template>
<script>
  export default {
    data () {
      return {
        tag: {
          'title': '工作台',
          'path': '/work'
        },
        columns11: [
          {
            title: ' ',
            key: 'dateDesc',
            align: 'center',
            minWidth: 80,
          },
          {
            title: '注册数量',
            key: 'registerCount',
            align: 'center',
            minWidth: 110,
          },
          {
            title: '申请量',
            align: 'center',
            children: [
              {
                title: '新户',
                key: 'newUserCount',
                align: 'center',
                minWidth: 110
              },
              {
                title: '老户',
                key: 'oldUserCount',
                align: 'center',
                minWidth: 110
              }
            ]
          },
          {
            title: '放款',
            align: 'center',
            children: [
              {
                title: '数量',
                key: 'loanCount',
                align: 'center',
                minWidth: 110
              },
              {
                title: '金额(元)',
                key: 'loanAmount',
                align: 'center',
                minWidth: 110,
                render:(h,params) => {
                  return h('div',this.toYuan(params.row.loanAmount))
                }
              }
            ]
          },
          {
            title: '到期',
            align: 'center',
            children: [
              {
                title: '入催数',
                key: 'collectionCount',
                align: 'center',
                minWidth: 110
              },
              {
                title: '入催金额(元)',
                key: 'collectionAmount',
                align: 'center',
                minWidth: 110,
                render:(h,params) => {
                  return h('div',this.toYuan(params.row.collectionAmount))
                }
              }
            ]
          },
          {
            title: '还款',
            align: 'center',
            children: [
              {
                title: '结清数',
                key: 'settleCount',
                align: 'center',
                minWidth: 110
              },
              {
                title: '回收金额(元)',
                key: 'settleAmount',
                align: 'center',
                minWidth: 110,
                render:(h,params) => {
                  return h('div',this.toYuan(params.row.settleAmount))
                }
              }
            ]
          },

        ],
        data10: []
      }
    },
    created(){
      this.getToday();
    },
    methods:{
      getToday () {
        this.$post('/bkworkbench/data')
          .then((res) => {
            if(res.code === 0){
              console.log(res)
              this.data10 = res.data;
            }
          })
      },
      // 转化为元
      toYuan(money){
        if(money){
          return (money/100).toFixed(2)
        }else{
          return 0
        }

      },
    },
    mounted () {
      this.$store.commit('changeTag', this.tag.path);
      this.$store.commit('openPage', this.tag);
      if(sessionStorage.getItem('load')){
        sessionStorage.removeItem('load');
        window.location.reload();
      }

    }
  }
</script>
